<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>竞技之星</title>
<link href="${path }/resource/css/scale-css.css" type="text/css" rel="stylesheet" />
<link href="${path }/resource/css/nativeShare.css" type="text/css" rel="stylesheet" />
<!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<script type="text/javascript" src="${path }/resource/js/scale.js"></script>
<script type="text/javascript" src="${path }/resource/js/nativeShare.js"></script>
</head>

<body class="body-bg">
	<div class="div-container">
	
		<div class="title-bg">
			<div class="div-title">竞技之星</div><br>
			<div class="sub-title" style="margin-top: -290px;margin-left: 260px;">跑得快</div>
		</div>
		<div class="div-bg div-line-bg5"></div>
		
	<div class="div-content" style="margin-top: -2px;">
		只需将以下推广页面分享给从未下载过本产品的好友，好友扫描下载《竞技之星》后您的推广账户上将自动获得5元推广金。若是您的好友在本产品消费，您还还将获得一定额度的奖励哦。还等什么，赶快行动！
	</div>
	<div class="div-bg div-line-bg2" style="margin-top: -1px;"></div>
	<div class="div-content1" style="margin-top: -1px;">
		您的ID:<span id="gameId" >${user.gameId}</span>   
		<input type="hidden" id="userId" value="${user.id }" /> 
		<input type="hidden" id="token" value="${user.weixinId }" /> 
		<span class="div-btn" id="share">立即分享</span>
		<br>
		<br>
		<br>
		您的推广金:<span id="extensionMoney">
		<c:if test="${empty user.extensionMoney}">
			0
		</c:if>
			${user.extensionMoney}
		</span>元
		<span class="div-btn" onclick="pickUpCash()" id="atOnceCash">立即提现</span>
		
		<span id="getCashDiv" style="display: none;">
			<input class="input-text" type="text" id="aliAccount"/>
			<span class="div-btn" onclick="drawCash()">提现</span>
		</span>
	</div>
	
	<div class="div-bg div-line-bg20"></div>
	<div class="div-content" style="margin-top: -1px;">推广详情</div>
	<div class="div-bg div-line-bg3"></div>
	
	<div id="prizeDetail" style="display: none;">
	<c:if test="${extensions ne null }">
			<c:forEach var="extension" items="${extensions}" varStatus="status">
	<div class="div-content1">
		ID:${extension.userId}		
		<span class="span-text1">${extension.strDate }${extension.descriptions }</span>
		<span class="span-text2">${extension.money }
			<c:if test="${extension.descriptions eq '下载奖励' }">钻</c:if>
			<c:if test="${extension.descriptions ne '下载奖励' }">元</c:if>
		</span>
	</div>
	<c:if test="${status.count ne extensions.size()}">
		<div class="div-line-black" style="margin-top: -1px;"></div>
	</c:if>
	</c:forEach>
	</c:if>
	</div>
	
	<div class="div-bg div-line-bg120">
		<span class="div-btn div-font-size" onclick="lookDetail()">查看奖励明细</span>
	</div>
	</div>
	<div id="nativeShare" style="background-color:#FFFFFF;z-index: 999;color: black;"></div>
	<div id="wxDiv" class="wx-tip" ><img id="wxImg" src="${path }/resource/images/weixin-tip.png"></img></div>
	
	<!-- <div class="-mob-share-ui  -mob-share-ui-theme -mob-share-ui-theme-slide-bottom" style="display: none;height: 200px;">
    <ul class="-mob-share-list">
			<li class="-mob-share-weibo"><p>新浪微博</p></li>
			<li class="-mob-share-tencentweibo"><p>腾讯微博</p></li>
			<li class="-mob-share-qzone"><p>QQ空间</p></li>
			<li class="-mob-share-qq"><p>QQ好友</p></li>
			<li class="-mob-share-weixin"><p>微信</p></li>
			<li class="-mob-share-douban"><p>豆瓣</p></li>
			<li class="-mob-share-renren"><p>人人网</p></li>
			<li class="-mob-share-kaixin"><p>开心网</p></li>
    </ul>
    <div class="-mob-share-close">取消</div>
</div>
<div class="-mob-share-ui-bg"></div>
<script id="-mob-share" src="http://f1.webshare.mob.com/code/mob-share.js?appkey=1654f87f61eb0"></script> -->
</body>
<script type="text/javascript">
$("#share").bind("click", function() {
	var userId = $("#userId").val();
	// window.location.href="${path}/client/shareUrl?userId="+userId;
	var gameId = $("#gameId").html();
	var token = $("#token").val();
	var url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5f684362422f302e&redirect_uri=http://www.jjstar.cc/client/getweixinInfo/'+userId+'&response_type=code&scope=snsapi_userinfo&state=3d6be0a4035d839573b04816624a416e#wechat_redirect';
    var config = {  
    		url:url,
            title:'竞技之星火爆来袭,首次下载送888RMB大礼包,还等神马?赶快行动吧！',
            desc:'竞技之星火爆来袭,首次下载送888RMB大礼包,还等神马?赶快行动吧！',
            img:'',
            img_title:'竞技之星',
            from:'竞技之星'
    }; 
    var share_obj = new nativeShare('nativeShare', config);
    $(".am-share").addClass("am-modal-active");  
    if ($(".sharebg").length > 0) {  
        $(".sharebg").addClass("sharebg-active");  
    } else {  
        $("body").append('<div class="sharebg"></div>');  
        $(".sharebg").addClass("sharebg-active");  
    }  
    $(".sharebg-active,.share_btn").click(function() {  
        $(".am-share").removeClass("am-modal-active");  
        setTimeout(function() {  
            $(".sharebg-active").removeClass("sharebg-active");  
            $(".sharebg").remove();  
        }, 300);  
    }) 
   /*  $.ajax({
	    type: "post",
	    url: "${path}/client/shareUrl",     
	    data: {"url":url,
	    		"gameId":gameId},    
	    success: function(data) {
	    	console.log(data);
	    	alert("data = "+data+"   code = "+data.code);
	    	if(data.code=="true"){
	    		var share_obj = new nativeShare('nativeShare', config);
		        $(".am-share").addClass("am-modal-active");  
		        if ($(".sharebg").length > 0) {  
		            $(".sharebg").addClass("sharebg-active");  
		        } else {  
		            $("body").append('<div class="sharebg"></div>');  
		            $(".sharebg").addClass("sharebg-active");  
		        }  
		        $(".sharebg-active,.share_btn").click(function() {  
		            $(".am-share").removeClass("am-modal-active");  
		            setTimeout(function() {  
		                $(".sharebg-active").removeClass("sharebg-active");  
		                $(".sharebg").remove();  
		            }, 300);  
		        })  
	    	} 
	    },
	    error: function(data) {
	    	alert("网络繁忙，请稍候再试！");
	    }
	    });  */
    
});
/* var weixin = mobShare( 'weixin' );
$( '#share' ).click( function() {
    weixin.send();
} ); */

/* mobShare.config( {
	 
    appkey: '1654f87f61eb0', // appkey
 
    params: {
        url: 'http://pay.jjstar.cc', // 分享链接
        title: '竞技之星—跑得快', // 分享标题
    }
 
} ); */

//提现
function pickUpCash(){
	var userId = $("#userId").val();
	var money = $("#extensionMoney").text();
	if(userId==""||userId==null){
		alert("您还没有登录，请先登录吧！");
		return false;
	}
	if(money<=0){
		alert("当前推广金为0,赶快去推广吧！");
		return false;
	}
	if(confirm("确定要提现吗？")){
		$("#atOnceCash").hide();
		$("#getCashDiv").show();
	}else{
	}
	
	
}

function drawCash(){
	var account = $("#aliAccount").val();
	var gameId = $("#gameId").text();
	
	var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
	if(!myreg.test(account)) 
	{ 
	    alert('请输入有效的手机号码！'); 
	    return false; 
	} 
	
	$.ajax({
	    type: "post",
	    url: "${path}/client/getCash",     
	    data: {"gameId":gameId,
	    		"account":account},    
	    success: function(data) {
	    	alert("申请成功！");
	    },
	    error: function(data) {
	    	alert("网络繁忙，请稍候再试！");
	    }
	    });
}	
		
function lookDetail(){
	$("#prizeDetail").show();
}

 $(window).on("load", function() {
    var winHeight = $(window).height();
    var width = $(window).width();
    function is_weixin() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
        } else {
            return false;
        }
    }
    var isWeixin = is_weixin();
    if (isWeixin) {
    	 $("#wxImg").css("height", winHeight);
    	 $("#wxImg").css("width", width);
         $("#wxDiv").show();
    }
}); 

</script>
</html>